home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Archive Magazine CD 1995
/
Archive Magazine CD 1995.iso
/
discs
/
shareware
/
share_41
/
assembler
/
examples
/
sum
< prev
next >
Wrap
Text File
|
1991-05-15
|
764b
|
28 lines
; NAME sum
; PURPOSE sums the numbers 0 to number1
; DESIGN
; result <- 0
; load number1
; for number1 <- number1 downto 0
; add number1 to result
; end for
; store result in number3
; NOTE
; sum to 50000 is maximum without overflow
; on arm 2 this takes 0.076 seconds
ldr r7, [r1] ; load number 1 to r7
mov r8, #0 ; set result r8 to zero
.loop
add r8, r8, r7 ; add number to result
sub r7, r7, #1 ; decrement the number
cmp r7, #0 ; has the number reached zero
bge loop ; branch if its greater than zero back round the loop
str r8, [r3] ; store the result in number 3